package com.slipper.system.collect.service;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.slipper.util.Tool;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import com.slipper.system.collect.dao.CollectTableLogDao;
import com.slipper.system.collect.bo.CollectTableLogBO;

import com.slipper.core.transaction.ReadTransactional;
import com.slipper.core.transaction.WriteTransactional;
import com.slipper.util.UUID;

@Service
@ReadTransactional
public class CollectTableLogService {
    @Resource
    private CollectTableLogDao collectTableLogDao;
    
    public CollectTableLogBO queryBy(String id) {
        return collectTableLogDao.queryBy(id);
    }
    
    public List<CollectTableLogBO> queryList(CollectTableLogBO bo) {
        return collectTableLogDao.queryList(bo);
    }
    
    public PageInfo<CollectTableLogBO> queryPage(CollectTableLogBO bo) {
        PageHelper.startPage(bo.getPageNumber(), bo.getPageSize());
        return new PageInfo<>(collectTableLogDao.queryList(bo));
    }
    
    @WriteTransactional
    public int save(CollectTableLogBO bo) {
        if (Tool.isNotBlank(bo.getId())) {
            return collectTableLogDao.update(bo);
        } else {
            bo.setId(UUID.getUUID());
            bo.setCreateTime(System.currentTimeMillis());
            return collectTableLogDao.insert(bo);
        }
    }

    @WriteTransactional
    public int insert(CollectTableLogBO bo) {
        bo.setCreateTime(System.currentTimeMillis());
        return collectTableLogDao.insert(bo);
    }

    @WriteTransactional
    public int update(CollectTableLogBO bo) {
        return collectTableLogDao.update(bo);
    }

    @WriteTransactional
    public int delete(CollectTableLogBO bo) {
        return collectTableLogDao.delete(bo);
    }
}
